#include<bits/stdc++.h>
using namespace std;
const int MAXN=4e4+10;
int n,pri[MAXN],phi[MAXN],tot,ans;
bool ispri[MAXN];
void cal_prime_phi()
{
    phi[1]=1;
    for(int i=2;i<MAXN;++i)
    {
        if(!ispri[i])
        {
            pri[++tot]=i;
            phi[i]=i-1;
        }
        for(int j=1;j<=tot&&i*pri[j]<=MAXN;++j)
        {
            ispri[i*pri[j]]=true;
            if(!(i%pri[j]))
            {
                phi[i*pri[j]]=phi[i]*pri[j];
                break;
            }
            else phi[i*pri[j]]=phi[i]*(pri[j]-1);
        }
    }
    return;
}
int main()
{
    scanf("%d",&n);
    cal_prime_phi();
    for(int i=2;i<n;++i)ans+=phi[i];
    printf("%d\n",ans*2+3);
    return 0;
}
